<template>
    <div>
        <el-form label-width="100px">
            <el-form-item label="id">{{mine.id}}</el-form-item>
            <el-form-item label="用户名">{{mine.name}}</el-form-item>
            <el-form-item label="email">{{mine.email}}</el-form-item>
            <el-form-item label="创建时间">{{mine.created_at}}</el-form-item>
            <el-form-item label="上次修改时间">{{mine.updated_at}}</el-form-item>
            <el-form-item label="修改密码">
                <el-input v-model="form.password" style="width: 200px;" type="password"></el-input>
            </el-form-item>
            <el-form-item label="确认密码">
                <el-input v-model="form.confirmPassword" style="width: 200px;" type="password"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="resetPassword" type="primary">确定</el-button>
            </el-form-item>
        </el-form>

    </div>
</template>

<script>
    export default {
        name: "Mine",
        data(){
            return{
                mine:{},
                form:{
                    id:'',
                    password:'',
                    confirmPassword:'',
                }
            }
        },
        mounted(){
            this.loadData();
        },
        methods:{
            loadData(){
                this.post('/api/mine/mine').then(result=>{
                    if(result.code === 0){
                        this.mine = result.data;
                        this.form.id = result.data.id;
                    }
                })
            },
            resetPassword(){
                this.post('/api/mine/reset_password',this.form).then(result=>{
                    if(result.code === 0){
                        this.$message.success(result.msg);
                    } else {
                        this.$message.error(result.msg);
                    }
                })
            },
        }
    }
</script>

<style scoped>

</style>